{template 'public/header'}

{template 'public/comhead'}

<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li  {if $type=='all'} class="active" {/if}><a href="{php echo $this->createWebUrl('branchslist',array('type'=>all));}">车辆收益</a></li>
</ul>
<br>
<div class="row ygrow">
    <div class="col-lg-12">

        <form class="form-inline" action="" method="get">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="goods_income" />
            <input type="hidden" name="token" value="{$_W['token']}"/>
            <div class="form-group">
                <label for="keyword">关键词</label>
                <input type="text" class="form-control" name="keywords" id="keyword" value="{$keywords}" placeholder="请输入订单号，车牌号">
            </div>
            <div class="form-group">
                <label for="branch_id">门店</label>
                <select class="form-control" id="branch_id" name="branch_id" style="width: 150px">
                    <option value="">请选择门店</option>
                    {loop $branch_list $index $item}
                    <option value="{$item['id']}" {if $branch_id == $item['id'] } selected {/if}>{$item['name']}</option>
                    {/loop}
                </select>
            </div>
<!--            <div class="form-group">-->
<!--                <label for="shuttle_id">交车员</label>-->
<!--                <select class="form-control" id="shuttle_id" name="shuttle_id" style="width: 150px">-->
<!--                    <option value="">请选择状态</option>-->
<!--                    {loop $shuttle_list $index $item}-->
<!--                    <option value="{$item['id']}" {if $shuttle_id == $item['id'] } selected {/if}>{$item['name']}</option>-->
<!--                    {/loop}-->
<!--                </select>-->
<!--            </div>-->
            <div class="form-group">
                <label for="distribution_id">经办人</label>
                <select class="form-control" id="distribution_id" name="distribution_id" style="width: 150px">
                    <option value="">请选择经办人</option>
                    {loop $distribution_list $index $item}
                    <option value="{$item['uid']}" {if $distribution_id == $item['uid'] } selected {/if}>{$item['name']}</option>
                    {/loop}
                </select>
            </div>

            <div class="form-group">
                <label >创建时间</label>
                {php echo tpl_form_field_daterange('range_time',array('start'=>date('Y-m-d H:i', $start_time),'end'=>date('Y-m-d H:i', $end_time)),true);}
            </div>
            <input type="submit"  name="submit"  value="搜索" class="btn btn-default">
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>
    </div><!-- /.col-lg-6 -->
</div>
<div class="row ygrow">
    <div class='col-lg-12'>
        <li><p style="margin-top: 6px;">总收入：<label style="color: red">{$total_revenue}</label></p></li>
        <li><p style="margin-top: 6px;">总费用：<label style="color: red">{$total_fees}</label></p></li>
        <li><p style="margin-top: 6px;">总实收：<label style="color: red">{$total_paid}</label></p></li>
        <li><p style="margin-top: 6px;">总利润：<label style="color: red">{$total_profit}</label></p></li>
        <li><p style="margin-top: 6px;">总差异：<label style="color: red">{$total_difference}</label></p></li>
    </div>
</div>
<a data-toggle="modal" data-target="#myModalsss"><button class="btn btn-xs storeblue">导出信息</button></a>
<div class="modal fade" id="myModalsss" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">客户租车信息导出</h4>
            </div>
            <form action="" method="get" >
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="yzzc_sun" />
                <input type="hidden" name="do" value="goods_income" />
                <input type="hidden" name="branch_id" value="{$branch_id}" />
                <input type="hidden" name="keywords" value="{$keywords}" />
                <input type="hidden" name="distribution_id" value="{$distribution_id}" />
                <input type="hidden" name="shuttle_id" value="{$shuttle_id}" />
                <input type="hidden" name="start_time" value="{$start_time}" />
                <input type="hidden" name="end_time" value="{$end_time}" />

                <input type="hidden" name="op" value="export_order" />
                <div class="modal-body" style="font-size: 20px">
                    <span>
                    即将导出所有订单？
                    </span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <input type="submit" class="btn btn-info" name="submit" value="确定"/>
                </div>
                <input type="hidden" name="token" value="{$_W['token']}"/>
            </form>
        </div>
    </div>
</div>
<div class="main ">

    <div class="panel panel-default" style="width: 2500px">
        <div class="panel-heading">
            收益列表
        </div>
        <div class="panel-body" style="padding: 0px 15px;width: 2500px">
            <div class="row" id="accordion">
                <table class="yg5_tabel col-md-12 table-hover">
                    <tr class="yg5_tr1">
                        <td class="store_td1 ">名称</td>
                        <td>门店</td>
                        <td>车牌</td>
                        <td>客户</td>
                        <td>送车人</td>
                        <td>经办人</td>
                        <td>租金/天</td>

                        <td>开始时间</td>
                        <td>结束时间</td>
                        <td>公里数</td>
                        <td>油量</td>
                        <td>发车时间</td>
                        <td>还车时间</td>

                        <td>保证金</td>
                        <td>退押金</td>
                        <td>总租金</td>
                        <td>超公里</td>
                        <td>超时</td>
                        <td>司机</td>

                        <td>送/收车费</td>
                        <td>油补</td>
                        <td>违章</td>
                        <td>车损</td>
                        <td>维修费</td>
                        <td>应收金额</td>

                        <td>超公里</td>
                        <td>中介</td>
                        <td>司机费用</td>
                        <td>报销</td>
                        <td>加油</td>
                        <td>违章</td>
                        <td>维修保养</td>

                        <td>费用合计</td>
                        <td>实际收入</td>
                        <td>利润</td>
                        <td>差异</td>
                        <td>备注</td>
                    </tr>

                    {loop $info $key $item}
                    <tbody>
                    <tr class="yg5_tr2" >
                        <td>{$item['car_name']}</td>
                        <td>{$item['branch_name']}</td>
                        <td>{$item['car_num']}</td>
                        <td>{$item['username']}</td>
                        <td>{$item['shuttle_name']}</td>
                        <td>{$item['distribution_name']}</td>
                        <td>{$item['money']}/{$item['day']}天</td>

                        <td>{$item['order_start_time']}</td>
                        <td>{$item['order_end_time']}</td>
                        <td>{$item['km_start']}起-{$item['km_end']}止</td>
                        <td>{$item['petrol_start']}起-{$item['petrol_end']}止</td>
                        <td>{$item['start_time']}</td>
                        <td>{$item['end_time']}</td>

                        <td>{$item['security']}</td>
                        <td>{$item['refund_deposit']}</td>
                        <td>{$item['total_money']}</td>
                        <td>{$item['exceed_km']}</td>
                        <td>{$item['exceed_time']}</td>
                        <td>{$item['driver_revenue']}</td>

                        <td>{$item['give_revenue']}</td>
                        <td>{$item['gasoline_subsidy_revenue']}</td>
                        <td>{$item['peccant_revenue']}</td>
                        <td>{$item['car_damage_revenue']}</td>
                        <td>{$item['repair_revenue']}</td>
                        <td>{$item['total_revenue']}</td>
                        <td>{$item['callout_cost']}</td>

                        <td>{$item['exceed_km_cost']}</td>
                        <td>{$item['intermediary_cost']}</td>
                        <td>{$item['driver_cost']}</td>
                        <td>{$item['reimbursement_cost']}</td>
                        <td>{$item['refueling_subsidies_cost']}</td>
                        <td>{$item['peccancy_cost']}</td>
                        <td>{$item['maintenance_cost']}</td>

                        <td>{$item['total_cost']}</td>
                        <td>{$item['paid_cost']}</td>
                        <td>{$item['profit_cost']}</td>
                        <td>{$item['difference_cost']}</td>
                        <td>{$item['remark']}</td>
                    </tr>
                    </tbody>
                    {/loop}
                    {if empty($info)}
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无收益信息
                        </td>
                    </tr>
                    {/if}
                </table>
            </div>
        </div>

    </div>
    </form>
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-2").show();
        $("#yframe-2").addClass("wyactive");
    })
    function del(id) {
        var ret = confirm("删除前请确认该门店所有车辆均已下架，您确定删除吗？")
        if (ret==true){
            $.ajax({
                type:"POST",
                url:"/web/index.php?c=site&a=entry&op=delete&do=branchslist&op=delete&module_name=yzzc_sun&version_id=1",
                dataType:"JSON",
                data:{id:id},
                success:function(res){
                    console.log(res);
                    location.reload();
                    // if(res.status == 1) {
                    //     layer.msg(res.message, {icon: 1});
                    //     location.href ="{php echo $this->createWebUrl('renting')}";
                    // }else{
                    //     layer.msg(res.message, {icon: 6});
                    //     location.href =res.url;
                    // }
                }
            })
        }
    }
</script>